/**
 * Kleiner Test der Bibliothek 
 * Arbeitet ausschliesslich im 4-Bit Modus
 *
 * (c) Copyright 2007 Enrico Homann <eh@tupperworx.de> http://www.tupperworx.de
 */


#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <stdio.h>
#include <stdlib.h>
/* #include <string.h> */

#include <math.h>

/* #define DEBUG */
 

/* MCU Frequenz Voreinstellung */
#ifndef F_CPU
#define F_CPU 20.0E6					
#endif

#include <util/delay.h>

/* Eigene Bibliotheken einbinden */
#include "pinlayout.h"
#include "lib/lcd/lcd_wd2704m.h"

/* Boolean definieren */
#ifndef BOOL
#define BOOL
typedef enum { false, true } bool;
#endif

int main() {

	/* LCD Kontroller Pins als Outputpins schalten ( DDRx = 1 ) */
	LCD_HD44780_DDR |= (1 << LCD_HD44780_D4) | (1 << LCD_HD44780_D5) | (1 << LCD_HD44780_D6) | (1 << LCD_HD44780_D7) | (1 << LCD_HD44780_RS) | (1 << LCD_HD44780_RW);

	/* LCD Kontroller Enable Pins als Outputpins schalten ( DDRx = 1 ) */
	LCD_HD44780_DDR_E |= (1 << LCD_HD44780_E1) | (1 << LCD_HD44780_E2);

	
	/* LCD Display initialisieren */
	lcd_wd2704m_init ( LCD_HD44780_COMMAND_FUNCTIONSET_4BIT_2LINES_5X8DOTS, LCD_HD44780_COMMAND_ENTRYMODESET_CURSOR_SHIFTRIGHT, LCD_HD44780_COMMAND_DISPLAYOFF );

	/* LCD Display einschalten */
	lcd_wd2704m_command ( LCD_HD44780_COMMAND_DISPLAYON_HIDECURSOR );

	char *s; s = malloc(27);					/* Eine Zeile sichern */
	uint8_t i;
	s = "Test\0";	

	while (1) {

		for (i = 0; i < 4; i++) lcd_wd2704m_writestrxy(i,i, s);
		

		
	}

	/* Scheintoter Bereich, kein Code wird hier mehr ausgefuehrt */
	
}
